package com.atliuzu.app.func;

import com.atliuzu.utils.KeywordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.io.IOException;

/**
 * @Author : songyuan
 * @Description :
 * Date : 2022/8/20 15:56
 * @Version : 1.0
 */


@FunctionHint(output = @DataTypeHint("ROW<word string>"))
public class KeywordUDTF extends TableFunction<Row> {
    public void eval(String text)  {

        try {
            for (String keyword : KeywordUtil.spiltKeyWord(text)) {
                collect(Row.of(keyword));
            }
        } catch (IOException e) {
            collect(Row.of(text));
        }

    }

}
